import axios from 'axios'

export function upload({
    url, params = {}, onUploadProgress = ()=>{}
}){
    const instance = axios.create({
        baseURL:'http:127.0.0.1:3005',
        onUploadProgress: function (progressEvent) {
            // 对原生进度事件的处理
            let complate = (progressEvent.loaded / progressEvent.total * 100 | 0)
            onUploadProgress(complate)
        },
    })

    // 请求拦截器
    instance.interceptors.request.use(config=>{

        return config
    },err=>{})

    // 响应拦截器
    instance.interceptors.response.use(config=>{

        return config
    },err=>{})

    return instance.post(url, params)
}